<?php

namespace common\models;

use Yii;
use common\models\Goods;

/**
 * This is the model class for table "active".
 *
 * @property integer $id
 * @property string $title
 * @property integer $time_begin
 * @property integer $time_end
 * @property integer $sys_dateline
 * @property integer $sys_lastmodify
 * @property integer $sys_status
 * @property string $sys_ip
 */
class Active extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'active';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['title', 'sys_ip'], 'required'],
            [['time_begin', 'time_end', 'sys_dateline', 'sys_lastmodify', 'sys_status'], 'integer'],
            [['title'], 'string', 'max' => 255],
            [['sys_ip'], 'string', 'max' => 50]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '活动id',
            'title' => '活动标题',
            'time_begin' => '活动开始时间',
            'time_end' => '活动结束时间',
            'sys_dateline' => '创建时间',
            'sys_lastmodify' => '更新时间',
            'sys_status' => '活动状态',
            'sys_ip' => '创建活动ip',
        ];
    }

    public function getGoods()
    {
        return $this->hasMany( Goods::className(),[ 'active_id' => 'id' ] );
    }
}
